package com.example.zsq.myapplicationservice;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.view.View.OnClickListener;
public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        Button bt_start, bt_stop;
        bt_start = (Button)findViewById(R.id.button1);
        bt_start.setOnClickListener(startit);
        bt_stop = (Button)findViewById(R.id.button2);
        bt_stop.setOnClickListener(stopit);
    }

    private OnClickListener startit = new OnClickListener() {
        public void onClick(View v)
        {
            startService(new Intent(MainActivity.this,Music.class));
        }
    };
    private OnClickListener stopit = new OnClickListener() {
        public void onClick(View v)
        {
            stopService(new Intent("com.example.zsq.myapplicationservice.START_AUDIO_SERVICE"));
        }
    };
}